package technology;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.benchmark.Producer;

import sun.java2d.pipe.BufferedBufImgOps;

import com.sun.star.installation.protocols;

public class MySender {
	public MySender(){
		try{
			ConnectionFactory factory=new ActiveMQConnectionFactory("tcp://0.0.0.0:61616");
			factory.createConnection();
			Connection connection=factory.createConnection();
			connection.start();
			Session session=connection.createSession(Boolean.TRUE,Session.AUTO_ACKNOWLEDGE);
			Destination destination=session.createQueue("queue");
			MessageProducer messageProducer=session.createProducer(destination);
			messageProducer.setDeliveryMode(DeliveryMode.PERSISTENT);
			ObjectMessage message=session.createObjectMessage();
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String line=br.readLine();
			while(!line.equals("exit")){
				message.setStringProperty("test",line);
				messageProducer.send(message);
				session.commit();
				line=br.readLine();
			}
		}catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	
	public static void main(String[] arg){
		//MyList myList=new MyList();
		MySender mySender=new MySender();
		
	}

}
